<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$setting=$this->plugin_setting('basic');
$return['banner']=$setting['hdps'];
$return['setting']=$setting;
if($_RQ['op']=='main'){
	$params=array('uniacid'=>$_SESSION['uniacid']);
	$return['params']=array();
	$zu_id=intval($_RQ['id']);
	if($zu_id){
		$return['params']['id']=$zu_id;
		$url=custom_url('jy_lineks/list/id='.$zu_id,true);
		$params['id']=$zu_id;
	}
	$group=pdo_get('jy_lineks_tiku_zu',$params);
	$return['group']=$group;
	$return['list']=array();
	$return['sharedata']=array(
		'title'=>$group['title'],
		'desc'=>$group['desc'],
		'link'=>$url,
		'imgUrl'=>tomedia($group['image']),
	);
	set_html('title',$group['title']);
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>'1');
	if($_RQ['id']){
		$params['zu_id']=intval($_RQ['id']);
	}
	if($_RQ['keyword']){
		$params['title like']='%'.trim($_RQ['keyword']).'%';
	}
	//状态为显示的所有活动，排序
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_lineks_list',$params,array($pindex,$psize),$total,$fields,'','createtime desc');
	if($list){
		foreach($list as &$item){
			if($item['mannum']-$item['num'] >= 0){
				$item['left']=$item['mannum']-$item['num'];
			}else{
				$item['left']=0;
			}
			$item['danum']=pdo_count('jy_lineks_canyu',array('uniacid'=>$_SESSION['uniacid'],'datiid'=>$item['id']));
			$item['createtime']=date('Y-m-d H:i:s', $item['createtime']);
			
		}
	}
	$return['list']=$list;
	exi($return);
}
